#pragma once

#include "discovery/eventfd_types.h"
#include <boost/asio.hpp>
#include <atomic>
#include <string>

using namespace boost::asio;

/**
 * EventFD 接收器基类
 */
class EventFdReceiver {
public:
    explicit EventFdReceiver(io_context& io, const std::string& identifier = "eventfd_transfer");
    virtual ~EventFdReceiver();
    
    /**
     * 启动接收器
     */
    virtual bool start() = 0;
    
    /**
     * 停止接收器
     */
    virtual void stop();
    
    /**
     * 设置EventFD接收回调
     */
    void set_transfer_callback(TransferCallback callback);
    
    /**
     * 设置连接状态回调
     */
    void set_connection_callback(ConnectionCallback callback);
    
    /**
     * 获取运行状态
     */
    bool is_running() const;

protected:
    io_context& io_;
    std::string identifier_;
    std::atomic<bool> running_;
    TransferCallback transfer_callback_;
    ConnectionCallback connection_callback_;
};
